﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZK.Common
{
    /// <summary>
    /// 硬件的通用类型 包括网口硬件 串口硬件
    /// </summary>
    public class HaredWareCommonM : ConfigurationElement
    {
        [ConfigurationProperty("Name", IsRequired = false)]
        public string Name
        {
            get { return this["Name"].ToString(); }
            set { this["Name"] = value; }
        }
        /// <summary>
        /// 串口名称
        /// </summary>
        [ConfigurationProperty("PortName", IsRequired = false)]
        public string PortName
        {
            get { return this["PortName"].ToString(); }
            set { this["PortName"] = value; }
        }
        [ConfigurationProperty("Ip", IsRequired = false)]
        public string Ip
        {
            get { return this["Ip"].ToString(); }
            set { this["Ip"] = value; }
        }

        [ConfigurationProperty("Port", IsRequired = false)]
        public string Port
        {
            get { return this["Port"].ToString(); }
            set { this["Port"] = value; }
        }

        [ConfigurationProperty("UserName", IsRequired = false)]
        public string UserName
        {
            get { return this["UserName"].ToString(); }
            set { this["UserName"] = value; }
        }

        [ConfigurationProperty("PassWord", IsRequired = false)]
        public string PassWord
        {
            get { return this["PassWord"].ToString(); }
            set { this["PassWord"] = value; }
        }

        [ConfigurationProperty("BaudRate", IsRequired = false)]
        public int BaudRate
        {
            get { return Convert.ToInt32(this["BaudRate"].ToString()); }
            set { this["BaudRate"] = value; }
        }

        [ConfigurationProperty("DataBits", IsRequired = false)]
        public int DataBits
        {
            get { return Convert.ToInt32(this["DataBits"].ToString()); }
            set { this["DataBits"] = value; }
        }

        [ConfigurationProperty("Width", IsRequired = false)]
        public int Width
        {
            get { return Convert.ToInt32(this["Width"].ToString()); }
            set { this["Width"] = value; }
        }

        [ConfigurationProperty("Height", IsRequired = false)]
        public int Height
        {
            get { return Convert.ToInt32(this["Height"].ToString()); }
            set { this["Height"] = value; }
        }

        [ConfigurationProperty("Parity", IsRequired = false)]
        public Parity Parity
        {
            // get; set;
            get { return (Parity)Enum.Parse(typeof(Parity), this["Parity"].ToString(), true); }
            set { this["Parity"] = value; }
        }

        [ConfigurationProperty("StopBits", IsRequired = false)]
        public StopBits StopBits
        {
            // get; set;
            get { return (StopBits)Enum.Parse(typeof(StopBits), this["StopBits"].ToString(), true); }
            set { this["StopBits"] = value; }
        }
    }
}
